package com.fugit.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 * Personal taglib management class. Display Header. To access to css
 * resources, the container project need to add the following annotation at the
 * end of the <web-app> in web.xml file : metadata-complete="false"
 * 
 * <web-app ....doctype... metadata-complete="false" ... id="" ....>
 * 
 * @author Jee3
 * 
 */
public class FuHead extends SimpleTagSupport {

	/**
	 * Force latest IE rendering engine or ChromeFrame if installed.
	 */
	private String renderMeta = "<!--[if IE]><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"><![endif]-->";
	/**
	 * Bootstrap CSS Toolkit styles. downloaded from
	 * http://blueimp.github.com/cdn/css/bootstrap.min.css
	 */
	private String bootstrapStyles = "<link rel=\"stylesheet\" href=\"fugit/css/bootstrap.min.css\">";

	/**
	 * Bootstrap styles for responsive website layout, supporting different
	 * screen sizes.
	 */
	private String responsiveStyles = "<link rel=\"stylesheet\" href=\"fugit/css/bootstrap-responsive.min.css\">";

	/**
	 * Bootstrap CSS fixes for IE6.
	 */
	private String ie6FixStyles = "<!--[if lt IE 7]><link rel=\"stylesheet\" href=\"fugit/css/bootstrap-ie6.min.css\"><![endif]-->";

	/**
	 * Bootstrap Image Gallery styles.
	 */
	private String galleryStyles = "<link rel=\"stylesheet\" href=\"fugit/css/bootstrap-image-gallery.min.css\">";

	/**
	 * CSS to style the file input field as button and adjust the Bootstrap
	 * progress bars.
	 */
	private String upbuttonStyles = "<link rel=\"stylesheet\" href=\"fugit/css/jquery.fileupload-ui.css\">";

	/**
	 * Shim to make HTML5 elements usable in older Internet Explorer versions.
	 * downloaded from http://html5shim.googlecode.com/svn/trunk/html5.js
	 */
	private String olderIEScript = "<!--[if lt IE 9]><script src=\"fugit/js/html5.js\"></script><![endif]-->";

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "FuTag [html=" + bootstrapStyles + "]";
	}

	@Override
	public void doTag() throws JspException, IOException {
		getJspContext().getOut().write(
				renderMeta + "\n" + bootstrapStyles + "\n" + responsiveStyles
						+ "\n" + ie6FixStyles + "\n" + galleryStyles + "\n"
						+ upbuttonStyles + "\n" + olderIEScript + "\n");
	}

}
